/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bio.jpa.entities;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Diego
 */
@Entity
@Table(name = "sequence", catalog = "biodb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Sequence.findAll", query = "SELECT s FROM Sequence s"),
    @NamedQuery(name = "Sequence.findByIdSequence", query = "SELECT s FROM Sequence s WHERE s.idSequence = :idSequence"),
    @NamedQuery(name = "Sequence.findByRawSeq", query = "SELECT s FROM Sequence s WHERE s.rawSeq = :rawSeq")})
public class Sequence implements Serializable, Comparable<Sequence> {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Basic(optional = false)
    @Column(name = "id_sequence")
    private Integer idSequence;
    @Lob
    @Size(max = 2147483647)
    @Column(name = "seq")
    private String seq;
    @Column(name = "raw_seq")
    private Integer rawSeq;
    @JoinColumn(name = "gen_fk", referencedColumnName = "id_gen")
    @ManyToOne(optional = false)
    private GenBank genFk;

    public Sequence() {
    }

    public Sequence(String seq, Integer rawSeq, GenBank genFk) {
        this.seq = seq;
        this.rawSeq = rawSeq;
        this.genFk = genFk;
    }

    public Integer getIdSequence() {
        return idSequence;
    }

    public void setIdSequence(Integer idSequence) {
        this.idSequence = idSequence;
    }

    public String getSeq() {
        return seq;
    }

    public void setSeq(String seq) {
        this.seq = seq;
    }

    public Integer getRawSeq() {
        return rawSeq;
    }

    public void setRawSeq(Integer rawSeq) {
        this.rawSeq = rawSeq;
    }

    public GenBank getGenFk() {
        return genFk;
    }

    public void setGenFk(GenBank genFk) {
        this.genFk = genFk;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSequence != null ? idSequence.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sequence)) {
            return false;
        }
        Sequence other = (Sequence) object;
        if ((this.idSequence == null && other.idSequence != null) || (this.idSequence != null && !this.idSequence.equals(other.idSequence))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bio.jpa.entities.Sequence[ idSequence=" + idSequence + " ]";
    }

    @Override
    public int compareTo(Sequence s) {
        return getRawSeq().compareTo(s.getRawSeq());
    }
}
